package BuildCommand;

# $Id: BuildCommand.pm 287 2010-07-18 14:30:34Z dolbanavt $
# $Date: 2010-07-18 17:30:55 +0300 (Вск, 18 Июл 2010) $
# $HeadURL: https://robosearch.googlecode.com/svn/branches/reborn/lib/BuildCommand.pm $
# $LastChangedRevision: 348 $

use parent qw( JIP::BaseClass Class::Accessor::Fast );
use JIP::ToolSet;
use Carp qw( croak );
use English qw( -no_match_vars );
use JIP::Utils qw( check_named_params );

our $VERSION = '1.0';

__PACKAGE__->follow_best_practice;

__PACKAGE__->mk_accessors( qw( conf log dbh  ) );

sub _init {
    my ( $self, $params_ref ) = @ARG;

    check_named_params(
        rules_ref  => {
            conf => { required => 1, defined  => 1 },
            log  => { required => 1, defined  => 1 },
            dbh  => { required => 1, defined  => 1 },
        },
        params_ref => $params_ref,
    );

    $self->set_conf( $params_ref->{'conf'} );
    $self->set_log( $params_ref->{'log'} );
    $self->set_dbh( $params_ref->{'dbh'} );

    return $self;
}

sub execute {
    croak 'execute() is abstract method';
}

sub _log_step_header {
    my ( $self, $name ) = @ARG;

    croak 'step_name required' unless defined $name;

    $self->get_log->Note('---------------------------------------------------');
    $self->get_log->Note( 'build step: '. $name );
    $self->get_log->Note('---------------------------------------------------');

    return 1;
}

1;

__END__

=head1 NAME

BuildCommand - базовый класс шагов билда БД.
За основу взят паттерн проектирования Command.

=head1 SYNOPSIS

    use BuildCommand;

    my $t = BuildCommand->new(
        conf => ,
        log  => ,
        dbh  => ,
    );

=head1 DESCRIPTION

=head1 DEPENDENCIES

Class::Accessor::Fast (from CPAN)

JIP::ToolSet (from base_lib)

JIP::BaseClass (from base_lib)

JIP::Utils (from base_lib)

=head1 AUTHOR

Vladimir Zhavoronkov, <dolbanavt (at) Google Mail>

http://dolbanavt.livejournal.com/

=head1 LICENSE AND COPYRIGHT

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

=cut
